package main

import "fmt"

func main() {

	s := "abcdefghigkllllqqq"

	maxLength := test(s)
	fmt.Println(maxLength)
}

func test(s string) int {

	start := 0
	maxLength := 0
	var lastOcurred = make(map[byte]int)

	for k, v := range []byte(s) {

		if lastId, ok := lastOcurred[v]; ok && lastId >= start {
			start = lastId + 1
		}

		if k-start+1 > maxLength {
			maxLength = k - start + 1
		}

		lastOcurred[v] = k

	}
	return maxLength
}
